﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace HYRElectric.WirePlace
{
	internal class ElementToBasisPointComparer : IComparer<Element>
	{
		public ElementToBasisPointComparer(XYZ refPoint)
		{
			this.m_ReferencePoint = new XYZ(refPoint.X, refPoint.Y, 0.0);
		}

		public int Compare(Element fi1, Element fi2)
		{
			LocationPoint locationPoint = fi1.Location as LocationPoint;
			LocationPoint locationPoint2 = fi2.Location as LocationPoint;
			XYZ xyz = new XYZ(locationPoint.Point.X, locationPoint.Point.Y, 0.0);
			XYZ xyz2 = new XYZ(locationPoint2.Point.X, locationPoint2.Point.Y, 0.0);
			return xyz.DistanceTo(this.m_ReferencePoint).CompareTo(xyz2.DistanceTo(this.m_ReferencePoint));
		}

		private XYZ m_ReferencePoint;
	}
}
